/*
 * CmdCommand.h
 *
 *  Created on: Sep 11, 2011
 *      Author: Gherman Alin
 */

#ifndef COMMANDLINE__CMDCOMMAND_H_
#define COMMANDLINE__CMDCOMMAND_H_

#include "../Worker/all.h"
#include <map>
#include <list>
#include <utility>

namespace CommandLine {

enum ParamKey {
	INVALID_PARAM,

	PARAM_PASS,
	PARAM_KEY,
	PARAM_STR_VALUE,
	PARAM_DATA_VALUE,
	PARAM_OLD_PASS,

	PARAM_CONTAINER,
	PARAM_PATH,
};

enum CmdType {
	INVALID_CMD,

	CMD_SET_CONTAINER,
	CMD_REMOVE_CONTAINER,
	CMD_LIST_CONTAINERS,

	CMD_LOAD_FILE,
	CMD_SAVE_FILE,
	CMD_QUIT,

	CMD_LIST,
	CMD_GET,
	CMD_SET,
	CMD_REMOVE,
};

class CmdCommand: public Worker::Command {
public:
	CmdCommand(const std::string& cmdLine);
	virtual ~CmdCommand();

	void onSuccess(const std::string& msg);
	void onFailure(const std::string& msg);

	CmdType getCmd();
	std::string* getParam(ParamKey key);
	std::list<std::string> getParams(ParamKey key);

	std::string helpMsg();

private:
	CmdType cmd;
	std::map<ParamKey, std::list<std::string> > params;

private:
	static const std::map<std::string, ParamKey> strToKeyMap;
	static const std::map<std::string, CmdType> strToCmdMap;
};

}

#endif
